{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 0.线性代数\n",
    "线性代数是数学的一个分支，它的研究对象是向量、向量空间（或称线性空间）、线性变换和有限维的线性方程组。向量空间是现代数学的一个重要课题；线性代数被广泛地应用于抽象代数和泛函分析中；通过解析几何，线性代数得以被具体表示。线性代数的理论已被泛化为算子理论。由于科学研究中的非线性模型通常可以被近似为线性模型，使得线性代数被广泛地应用于自然科学和社会科学中。\n",
    "\n",
    "线性关系意即数学对象之间的关系是以一次形式来表达的。例如，在解析几何里，平面上直线的方程是二元一次方程；空间平面的方程是三元一次方程，而空间直线视为两个平面相交，由两个三元一次方程所组成的方程组来表示。含有 n个未知量的一次方程称为线性方程。变于关量是一次的函数称为线性函数。线性关系问题简称线性问题。解线性方程组的问题是最简单的线性问题。其中：\n",
    "* 线性（linear）指量与量之间按比例、成直线的关系，在数学上可以理解为一阶导数为常数的函数\n",
    "* 非线性（non-linear）则指不按比例、不成直线的关系，一阶导数不为常数。\n",
    "\n",
    "线性代数的概念对于理解机器学习背后的原理非常重要，尤其是在深度学习领域中。它可以帮助我们更好地理解算法内部到底是怎么运行的，借此，我们就能够更好的做出决策。所以，理解机器学习具体算法，就不可避免需要精通这些线性代数的概念。\n",
    "## 0.1.环境、库"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import numpy as np\n",
    "import sympy as sp\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import itertools\n",
    "plt.rcParams['font.sans-serif'] = ['SimHei'] #指定默认字体   \n",
    "plt.rcParams['axes.unicode_minus'] = False #解决保存图像是负号'-'显示为方块的问题\n",
    "x, y, z, t = sp.symbols('x y z t')\n",
    "k, m, n = sp.symbols('k m n', integer=True)\n",
    "f, g, h = sp.symbols('f g h', cls=sp.Function)\n",
    "sp.init_printing()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1.行列式\n",
    "在以往的学习中，我们接触过二元、三元等简单的线性方程组。但是，从许多实践或理论问题里导出的线性方程组常常含有相当多的未知量，并且未知量的个数与方程的个数也不一定相等。\n",
    "\n",
    "我们先讨论未知量的个数与方程的个数相等的特殊情形。在讨论这一类线性方程组时，我们引入行列式这个计算工具。学习行列式主要就是要能计算行列式的值和求解线性方程组。\n",
    ">内容提要：\n",
    "1. 行列式的概念\n",
    "    1. 二阶与三阶行列式\n",
    "    2. 全排列及其逆序数\n",
    "    3. n阶行列式的定义\n",
    "2. 行列式的性质及计算\n",
    "    4. 对换\n",
    "    5. 行列式的性质\n",
    "    6. 行列式按行（列）展开\n",
    "3. 线性方程组的求解\n",
    "    7. 克拉默法则"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# common tool function\n",
    "def getM(var_name,r,c):\n",
    "    \"\"\"\n",
    "    make a sympy s matrix\n",
    "    :param var_name:the symbol name\n",
    "    :param r:matrix s rows\n",
    "    :param c:matrix s cols\n",
    "    \"\"\"\n",
    "    if r>1 and c>1:\n",
    "        ss=sp.symbols(\"{0}_{{{{0:{1}}}{{0:{2}}}}}\".format(var_name,r,c))        \n",
    "    elif r==1:\n",
    "        ss=sp.symbols(\"{0}_{{0:{1}}}\".format(var_name,c))\n",
    "    elif c==1:\n",
    "        ss=sp.symbols(\"{0}_{{0:{1}}}\".format(var_name,r))\n",
    "    else:\n",
    "        raise Exception('invalid input parameter！')\n",
    "    return sp.Matrix([ss[i*c:(i+1)*c] for i in range(r)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{0}{0}}  a_{{0}{1}}  a_{{0}{2}}⎤\n",
       "⎢                                  ⎥\n",
       "⎢a_{{1}{0}}  a_{{1}{1}}  a_{{1}{2}}⎥\n",
       "⎢                                  ⎥\n",
       "⎣a_{{2}{0}}  a_{{2}{1}}  a_{{2}{2}}⎦"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "getM('a',3,3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.1.二阶与三阶行列式\n",
    "我们从最简单的二元线性方程组出发，探求其求解公式，并设法化简此公式。\n",
    "### 1.1.1二元线性方程组与二阶行列式\n",
    "我们定义如下矩阵，构造方程组如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{0}{0}} x_{0} + a_{{0}{1}} x_{1}\\\\a_{{1}{0}} x_{0} + a_{{1}{1}} x_{1}\\end{matrix}\\right] = \\left[\\begin{matrix}b_{0}\\\\b_{1}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{0}{0}}⋅x_{0} + a_{{0}{1}}⋅x_{1}⎤   ⎡b_{0}⎤\n",
       "⎢                                   ⎥ = ⎢     ⎥\n",
       "⎣a_{{1}{0}}⋅x_{0} + a_{{1}{1}}⋅x_{1}⎦   ⎣b_{1}⎦"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xn=2\n",
    "xa,xb,xx=getM('a',xn,xn),getM('b',xn,1),getM('x',xn,1)\n",
    "expr=sp.Eq(xa*xx,xb)\n",
    "expr"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "采用高斯消元法求解，当分母项$\\not =0$时，该方程组有唯一解，如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}}\\\\a_{{1}{0}} & a_{{1}{1}}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{0}{0}}  a_{{0}{1}}⎤\n",
       "⎢                      ⎥\n",
       "⎣a_{{1}{0}}  a_{{1}{1}}⎦"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAU8AAAAjCAYAAAAUjIhnAAAABHNCSVQICAgIfAhkiAAAB81JREFUeJztnXuoFkUYh59TKml2r5OaJ6mstChNMpLSjCzR0soMCQuM6o8kKSS6iIjdMLIipHsQJ0rKEirtZnk5JUV2L8FI05IyrbxghpVmpz/eXc5xz+7s7M7Mt9+u88BSzu68+76zv292d3bmPeDxeDwe6/QB7gWOLNqREnAf8F7RTjiiyrFVnapeO9dx9QKuA7omHbCfovIQ4GXgJWCzXb8qyUDg66KdcESVY6s6Vb12ruP6DdgDLAeOzVKxC7AWGOTAqaqyAbjagd1mYKYDu1lwFZvHPVW9drWKayTSgXYg6clzNLAF+MKVRwUzA/gG+BP4HXgWOMDA3lHIY/5/wBJgJ3JXPNvMzczYjgvqJ7aqU9VrV/a4FgFNwGDdCg8D8xw4Ug80AHcB5yBjuiOQu9gdBjYvAlqRm815QD/gbWA90MnEWfSfPF3EBW5j8whVvXZViesD4Hbdg19Hxjr3FZ5GOqmQ0cB3wBpgcrvyBcA2YH6k/m3AP4hAQk5HLnDflLppNJP/tT0aV5IPKt/SYktqK48ZuppUtb9LXeZFV5OmcdnUZUvgtxZLKE/nORNpNNU2vN3xTcAcYCWwFXmd2A3cE+zvhDR4E9ANWAX0DPadD4yh44V+EZgbKTshOPdJKXWjTAt8CrfdwK5I2dCYemlxqXxQ+ZYWW1Jbef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{{0}{0}} b_{1} - a_{{1}{0}} b_{0}}{a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}}\\right \\}$$"
      ],
      "text/plain": [
       "⎧            -a_{{0}{1}}⋅b_{1} + a_{{1}{1}}⋅b_{0}                  a_{{0}{0}}⋅\n",
       "⎨x_{0}: ─────────────────────────────────────────────, x_{1}: ────────────────\n",
       "⎩       a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}{1}}⋅a_{{1}{0}}         a_{{0}{0}}⋅a_{{1\n",
       "\n",
       "b_{1} - a_{{1}{0}}⋅b_{0}     ⎫\n",
       "─────────────────────────────⎬\n",
       "}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⎭"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xs=sp.solve(expr,xx)\n",
    "xs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从方程组解的公式中，能够观察到：\n",
    "1. 分母相同，有方程组的四个系数确定；\n",
    "2. 分子、分母都是四个系数分成两对相乘再相减而得。\n",
    "\n",
    "在此，我们先来引入相关基本符号：\n",
    ">* $A\\in\\mathbb{R}^{m\\times n}$表示一个$m行n列$的矩阵，并且矩阵$A$中的所有元素都是实数;\n",
    "* $X\\in\\mathbb{R}^n$表示一个含有$n$个元素的向量。通常，我们把$n$维向量看成是一个$n行1列$矩阵，即列向量。如果我们想表示一个行向量（$1行n列$矩阵），我们通常写作$x^T$ ($x^T$表示$x$的转置，后面会解释它的定义);\n",
    "* 一个向量$X$的第i个元素表示为$x_i$:$X=\\begin{bmatrix}x_1\\\\x_2\\\\\\vdots\\\\x_n\\end{bmatrix}$;\n",
    "* $a_{ij}或者a_{i,j}$表示矩阵$A$的$第i行j列$的元素:$A=\\begin{bmatrix}a_{11}&\\dots&a_{1n}\\\\\\vdots&\\ddots&\\vdots\\\\a_{m1}&\\dots&a_{mn}\\end{bmatrix}$;\n",
    "* $a_{:,j}$表示$A$矩阵的第$j$列元素:$A=\\begin{bmatrix}a_{:,1}&\\dots&a_{:,n}\\end{bmatrix}$;\n",
    "* $a_{i,:}$表示$A$矩阵的第$i$行元素:$A=\\begin{bmatrix}a_{1,:}\\\\\\vdots\\\\a_{m,:}\\end{bmatrix}$\n",
    "\n",
    "上述方程组是由矩阵$A$、向量$B$(一维行向量)和解向量$X$组成，方程组解向量$X$的分母由矩阵$A$的元素组成，我们称该分母为矩阵$A$的行列式，符号表述:行列式$D=|A|$。\n",
    "\n",
    "二阶行列式的计算，采用对角线法则，即矩阵$A$主对角线上的两元素之积，减去副对角线上的两元素之积。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( \\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}}\\\\a_{{1}{0}} & a_{{1}{1}}\\end{matrix}\\right], \\quad \\left \\{ x_{0} : \\frac{- a_{{0}{1}} b_{1} + a_{{1}{1}} b_{0}}{a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}}, \\quad x_{1} : \\frac{a_{{0}{0}} b_{1} - a_{{1}{0}} b_{0}}{a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}}\\right \\}, \\quad a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}\\right )$$"
      ],
      "text/plain": [
       "⎛⎡a_{{0}{0}}  a_{{0}{1}}⎤  ⎧            -a_{{0}{1}}⋅b_{1} + a_{{1}{1}}⋅b_{0}  \n",
       "⎜⎢                      ⎥, ⎨x_{0}: ───────────────────────────────────────────\n",
       "⎝⎣a_{{1}{0}}  a_{{1}{1}}⎦  ⎩       a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}{1}}⋅a_{{1}{0\n",
       "\n",
       "                a_{{0}{0}}⋅b_{1} - a_{{1}{0}}⋅b_{0}     ⎫                     \n",
       "──, x_{1}: ─────────────────────────────────────────────⎬, a_{{0}{0}}⋅a_{{1}{1\n",
       "}}         a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⎭                     \n",
       "\n",
       "                          ⎞\n",
       "}} - a_{{0}{1}}⋅a_{{1}{0}}⎟\n",
       "                          ⎠"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa,xs,xa[0,0]*xa[1,1]-xa[0,1]*xa[1,0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们拓展如下矩阵："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( \\left[\\begin{matrix}b_{0} & a_{{0}{1}}\\\\b_{1} & a_{{1}{1}}\\end{matrix}\\right], \\quad \\left[\\begin{matrix}a_{{0}{0}} & b_{0}\\\\a_{{1}{0}} & b_{1}\\end{matrix}\\right]\\right )$$"
      ],
      "text/plain": [
       "⎛⎡b_{0}  a_{{0}{1}}⎤  ⎡a_{{0}{0}}  b_{0}⎤⎞\n",
       "⎜⎢                 ⎥, ⎢                 ⎥⎟\n",
       "⎝⎣b_{1}  a_{{1}{1}}⎦  ⎣a_{{1}{0}}  b_{1}⎦⎠"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa0=xa.copy()\n",
    "xa0[:,0]=xb\n",
    "xa1=xa.copy()\n",
    "xa1[:,1]=xb\n",
    "xa0,xa1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "能够观察到，方程组解的分子，分别是矩阵$A0和A1$的行列式$|A0|和|A1|$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA2oAAAAjCAYAAADllPkyAAAABHNCSVQICAgIfAhkiAAAD0hJREFUeJztnXmQH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IVgLXIlOfJiEGW83akfV7gRs6rpkLfMZw3DZfkM5pUgfXlAayGHH7lF90i4Q8+prkyqNvWnlNoof4QUhfAXmrrzbXV/sZGoa3idi0w0W31T2k1ymbc+pKmr168KObbb6+nr1tpe73s270UG39bpt/V9FGQ7v9D/z5iWu+85EXB/8nKfTmycicz9mGzB6nuC9eABcGv6I5EJlbOpu1C/h6kagtDwZ/j0fCeoY8hURdWZVw3DbfvKwMfi7k0TdvvklkKa+u9GOO/pcH9dXm+moXEgm36di0w0W31f2k1ymbc+pKmr368aObbb6+nr1tpe73s270U239bpt/V9FGQ7v9D/z5iUu+2yIvved3HowGEwnpR4KKTEtIB4m8UuRAzRcvIJ8+D0GMcAIyP/Ql1nas4m7igOG4bb5VkEffvPkmkaW84Yj6anN9dWsspysoiqIoiqJE+DrSXxnU50gaqIHsB3AiyV/dFiBvracXIZ1HbgEuRjbzvgcJ63klEl4zNMbTyJqUkAnAM4bjtvlWQR598+abRJbyhiPqq8301QOA54B7U85TFEVRFEWJMgOJIHmf64XbAJ81pL87yPRIzIO+ujMCWI500EYhAQTGG4670EP2dT++SNOrh+xyxV1bhB0VQX21Xr46HZl3vkNGGRRFURRFGb5sAZySJ4O0DWI3AI4CNslTSA2YhYTNXI58ekw7bsPtyAZ9a5C1LntappVBkl555DJdm8eOymDUV/PLVYSvdiON61iHchVFURRFUUJGVS2AoiiKoiiKoiiKoiiKoiiKoiiKoiiKoiiKoiiKoiiKoiiKoiiKoiiKoiiKoiiKoiiKoigl8D9dSyMueq/3OAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left ( \\left \\{ x_{0} : \\frac{- a_{{0}{1}} b_{1} + a_{{1}{1}} b_{0}}{a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}}, \\quad x_{1} : \\frac{a_{{0}{0}} b_{1} - a_{{1}{0}} b_{0}}{a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}}\\right \\}, \\quad a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}, \\quad - a_{{0}{1}} b_{1} + a_{{1}{1}} b_{0}, \\quad a_{{0}{0}} b_{1} - a_{{1}{0}} b_{0}\\right )$$"
      ],
      "text/plain": [
       "⎛⎧            -a_{{0}{1}}⋅b_{1} + a_{{1}{1}}⋅b_{0}                  a_{{0}{0}}\n",
       "⎜⎨x_{0}: ─────────────────────────────────────────────, x_{1}: ───────────────\n",
       "⎝⎩       a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}{1}}⋅a_{{1}{0}}         a_{{0}{0}}⋅a_{{\n",
       "\n",
       "⋅b_{1} - a_{{1}{0}}⋅b_{0}     ⎫                                               \n",
       "──────────────────────────────⎬, a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}{1}}⋅a_{{1}{0}}\n",
       "1}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⎭                                               \n",
       "\n",
       "                                                                           ⎞\n",
       ", -a_{{0}{1}}⋅b_{1} + a_{{1}{1}}⋅b_{0}, a_{{0}{0}}⋅b_{1} - a_{{1}{0}}⋅b_{0}⎟\n",
       "                                                                           ⎠"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xs,xa.det(),xa0.det(),xa1.det()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "综上，线性方程组的解表示为：${{x_0=\\frac{|A0|}{|A|},x_1=\\frac{|A1|}{|A|}}}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.1.2.三阶行列式\n",
    "我们建立如下三元线性方程组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{0}{0}} x_{0} + a_{{0}{1}} x_{1} + a_{{0}{2}} x_{2}\\\\a_{{1}{0}} x_{0} + a_{{1}{1}} x_{1} + a_{{1}{2}} x_{2}\\\\a_{{2}{0}} x_{0} + a_{{2}{1}} x_{1} + a_{{2}{2}} x_{2}\\end{matrix}\\right] = \\left[\\begin{matrix}b_{0}\\\\b_{1}\\\\b_{2}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{0}{0}}⋅x_{0} + a_{{0}{1}}⋅x_{1} + a_{{0}{2}}⋅x_{2}⎤   ⎡b_{0}⎤\n",
       "⎢                                                      ⎥   ⎢     ⎥\n",
       "⎢a_{{1}{0}}⋅x_{0} + a_{{1}{1}}⋅x_{1} + a_{{1}{2}}⋅x_{2}⎥ = ⎢b_{1}⎥\n",
       "⎢                                                      ⎥   ⎢     ⎥\n",
       "⎣a_{{2}{0}}⋅x_{0} + a_{{2}{1}}⋅x_{1} + a_{{2}{2}}⋅x_{2}⎦   ⎣b_{2}⎦"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xn=3\n",
    "xa,xb,xx=getM('a',xn,xn),getM('b',xn,1),getM('x',xn,1)\n",
    "expr=sp.Eq(xa*xx,xb)\n",
    "expr"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "采用高斯消元法求解，当分母项$\\not =0$时，该方程组有唯一解，如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABk0AAAAjCAYAAAA5Qk3ZAAAABHNCSVQICAgIfAhkiAAAFylJREFUeJztnX/wLlVdx18XrvwSxuSHCXJlGiBTRH5kpIb0SDVMGJNZRjhpzGDNSFGOMjUyjX3LMTLCSaZMYdIHHTTQKH8WaWVUzhAyCOQtAdERyAjkRzKmQt7+OM/G3r17zp49P3bPeZ73a+Y7cM/z3c85n8++95z3d/fZXRBCCCGEEEIIIYQQQgghhBCDPAV4A/BDcw+kEN4CfDJw26cC9wFHpxuOyMSHgNdnjB+jI5CWaqJkLUlHdZFbS6J8tHZsDlo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yPbxJCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCPF/3KBNiNSpOfkAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\left \\{ x_{0} : \\frac{b_{0} \\left(a_{{1}{1}} a_{{2}{2}} - a_{{1}{2}} a_{{2}{1}}\\right) - b_{1} \\left(a_{{0}{1}} a_{{2}{2}} - a_{{0}{2}} a_{{2}{1}}\\right) + b_{2} \\left(a_{{0}{1}} a_{{1}{2}} - a_{{0}{2}} a_{{1}{1}}\\right)}{a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}}, \\quad x_{1} : \\frac{- b_{0} \\left(a_{{1}{0}} a_{{2}{2}} - a_{{1}{2}} a_{{2}{0}}\\right) + b_{1} \\left(a_{{0}{0}} a_{{2}{2}} - a_{{0}{2}} a_{{2}{0}}\\right) - b_{2} \\left(a_{{0}{0}} a_{{1}{2}} - a_{{0}{2}} a_{{1}{0}}\\right)}{a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}}, \\quad x_{2} : \\frac{b_{0} \\left(a_{{1}{0}} a_{{2}{1}} - a_{{1}{1}} a_{{2}{0}}\\right) - b_{1} \\left(a_{{0}{0}} a_{{2}{1}} - a_{{0}{1}} a_{{2}{0}}\\right) + b_{2} \\left(a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}\\right)}{a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}}\\right \\}$$"
      ],
      "text/plain": [
       "⎧                            b_{0}⋅(a_{{1}{1}}⋅a_{{2}{2}} - a_{{1}{2}}⋅a_{{2}{\n",
       "⎨x_{0}: ──────────────────────────────────────────────────────────────────────\n",
       "⎩       a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - \n",
       "\n",
       "1}}) - b_{1}⋅(a_{{0}{1}}⋅a_{{2}{2}} - a_{{0}{2}}⋅a_{{2}{1}}) + b_{2}⋅(a_{{0}{1\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2\n",
       "\n",
       "}}⋅a_{{1}{2}} - a_{{0}{2}}⋅a_{{1}{1}})                                        \n",
       "───────────────────────────────────────────────────────────, x_{1}: ──────────\n",
       "}}⋅a_{{1}{0}}⋅a_{{2}{1}} - a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}         a_{{0}{0}}\n",
       "\n",
       "           -b_{0}⋅(a_{{1}{0}}⋅a_{{2}{2}} - a_{{1}{2}}⋅a_{{2}{0}}) + b_{1}⋅(a_{\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{1}}⋅a_{{1}{\n",
       "\n",
       "{0}{0}}⋅a_{{2}{2}} - a_{{0}{2}}⋅a_{{2}{0}}) - b_{2}⋅(a_{{0}{0}}⋅a_{{1}{2}} - a\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{\n",
       "\n",
       "_{{0}{2}}⋅a_{{1}{0}})                                                  b_{0}⋅(\n",
       "─────────────────────────────────────────, x_{2}: ────────────────────────────\n",
       "2}{1}} - a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}         a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}\n",
       "\n",
       "a_{{1}{0}}⋅a_{{2}{1}} - a_{{1}{1}}⋅a_{{2}{0}}) - b_{1}⋅(a_{{0}{0}}⋅a_{{2}{1}} \n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a\n",
       "\n",
       "- a_{{0}{1}}⋅a_{{2}{0}}) + b_{2}⋅(a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}{1}}⋅a_{{1}{0}\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} - a_{{0}{2}\n",
       "\n",
       "})                     ⎫\n",
       "───────────────────────⎬\n",
       "}⋅a_{{1}{1}}⋅a_{{2}{0}}⎭"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xs=sp.solve(expr,xx)\n",
    "xs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "三元线性方程组的解，由行列式表达如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBOR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{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}}, \\quad \\frac{- a_{{0}{0}} a_{{1}{2}} b_{2} + a_{{0}{0}} a_{{2}{2}} b_{1} + a_{{0}{2}} a_{{1}{0}} b_{2} - a_{{0}{2}} a_{{2}{0}} b_{1} - a_{{1}{0}} a_{{2}{2}} b_{0} + a_{{1}{2}} a_{{2}{0}} b_{0}}{a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}}, \\quad \\frac{a_{{0}{0}} a_{{1}{1}} b_{2} - a_{{0}{0}} a_{{2}{1}} b_{1} - a_{{0}{1}} a_{{1}{0}} b_{2} + a_{{0}{1}} a_{{2}{0}} b_{1} + a_{{1}{0}} a_{{2}{1}} b_{0} - a_{{1}{1}} a_{{2}{0}} b_{0}}{a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}}\\right ]$$"
      ],
      "text/plain": [
       "⎡               a_{{0}{1}}⋅a_{{1}{2}}⋅b_{2} - a_{{0}{1}}⋅a_{{2}{2}}⋅b_{1} - a_\n",
       "⎢─────────────────────────────────────────────────────────────────────────────\n",
       "⎣a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{\n",
       "\n",
       "{{0}{2}}⋅a_{{1}{1}}⋅b_{2} + a_{{0}{2}}⋅a_{{2}{1}}⋅b_{1} + a_{{1}{1}}⋅a_{{2}{2}\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{\n",
       "\n",
       "}⋅b_{0} - a_{{1}{2}}⋅a_{{2}{1}}⋅b_{0}                                -a_{{0}{0\n",
       "────────────────────────────────────────────────────, ────────────────────────\n",
       "1}{0}}⋅a_{{2}{1}} - a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}  a_{{0}{0}}⋅a_{{1}{1}}⋅a_\n",
       "\n",
       "}}⋅a_{{1}{2}}⋅b_{2} + a_{{0}{0}}⋅a_{{2}{2}}⋅b_{1} + a_{{0}{2}}⋅a_{{1}{0}}⋅b_{2\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}}\n",
       "\n",
       "} - a_{{0}{2}}⋅a_{{2}{0}}⋅b_{1} - a_{{1}{0}}⋅a_{{2}{2}}⋅b_{0} + a_{{1}{2}}⋅a_{\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       " + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} - a_{{0\n",
       "\n",
       "{2}{0}}⋅b_{0}                               a_{{0}{0}}⋅a_{{1}{1}}⋅b_{2} - a_{{\n",
       "───────────────────────────, ─────────────────────────────────────────────────\n",
       "}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}  a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{0}{0}}⋅a_{\n",
       "\n",
       "0}{0}}⋅a_{{2}{1}}⋅b_{1} - a_{{0}{1}}⋅a_{{1}{0}}⋅b_{2} + a_{{0}{1}}⋅a_{{2}{0}}⋅\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "{1}{2}}⋅a_{{2}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a_{{1}{2}}⋅\n",
       "\n",
       "b_{1} + a_{{1}{0}}⋅a_{{2}{1}}⋅b_{0} - a_{{1}{1}}⋅a_{{2}{0}}⋅b_{0}             \n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "a_{{2}{0}} + a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} - a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0\n",
       "\n",
       "  ⎤\n",
       "──⎥\n",
       "}}⎦"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xab=[xa.copy() for _ in range(xn)]\n",
    "for i in range(xn):xab[i][:,i]=xb\n",
    "xad=xa.det()\n",
    "[i.det()/xad for i in xab]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "分子化简对比"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABfEAAAAjCAYAAAA0akBvAAAABHNCSVQICAgIfAhkiAAAEtVJREFUeJztnV/IdVldxz+vvaIzeVGNyczoWxdqKDI5ig1ZM3TEaNCaEAnKi5EBCUqQuqgQCXlCJOhSukgv5GgzCGZEA9lFVhIhMUbNjDCgo/LEjBVNziQjYo7N28U+mzmz373+r9/aa53n+4GD417P+u31+67fWt/17sM5B4QQQgghhBBCCCGEEEIIMQwPAp8G9sDvbjuUzfkw8DdbD2IQpFUa0iseaZWG9EpDegkLVFdpSK94pFUa0isN6RWPtLqYaN7TkF7xSKs0pFc80iqNXvS6nem5/B54ALgT4PLKH74e+A3gnxoNrGduBR7aehCDIK3SkF7xSKs0pFca0ktYoLpKQ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66OFrW49b7d2vsszxBr92tB63NY6HqIXmuxBPl7OfL3Osjfy5G/10H+Xs5F9fdzEr4TP8Rl4KtMX8h/HdMX8t8c0RbLjnoiXgI+xfr3WfnaWuDSykrDknxDfdfu14IYrXbUM5eSuRmxFmd21DVoi1qssW5K8N2/xvzuaFOLrvu1wpWXhYaxbS56rcXeae19MW0uXHPc855toaPl+WHtfq1o7X0W+3bPtTizo56OVrW49b7d2vsszxBr92tB63NY6LqPnmuxBPl7OfL3Osjfy5G/10H+Xs5F9fdzPA/xH2T69eV7gfdHDu4u4CuHQbwvoS3E54AngO8wfUfQmwPXQ9wOPMuU4/y6JaKtFS6tLDQsydfXN3duauHTqmRsrr65czNqLVpoaFWLJeumBq77l85vy1r03a8Va3lZaRhq89FzLfZOS+8LtflwzXHPe3aoLcSaVlZ7tut+LWnpfb77hRi1FmvraFmLW+/brb3P4gzR63q20tHi/ODLYwTk7+XI3+sgfy9H/l4H+Xs5F8Xf72B6Ln8v8ABwZ3wqQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIUQ6/w/ISPqyhnW5LQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left [ \\frac{a_{{0}{1}} a_{{1}{2}} b_{2} - a_{{0}{1}} a_{{2}{2}} b_{1} - a_{{0}{2}} a_{{1}{1}} b_{2} + a_{{0}{2}} a_{{2}{1}} b_{1} + a_{{1}{1}} a_{{2}{2}} b_{0} - a_{{1}{2}} a_{{2}{1}} b_{0}}{a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}}, \\quad - \\frac{a_{{0}{0}} a_{{1}{2}} b_{2} - a_{{0}{0}} a_{{2}{2}} b_{1} - a_{{0}{2}} a_{{1}{0}} b_{2} + a_{{0}{2}} a_{{2}{0}} b_{1} + a_{{1}{0}} a_{{2}{2}} b_{0} - a_{{1}{2}} a_{{2}{0}} b_{0}}{a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}}, \\quad \\frac{a_{{0}{0}} a_{{1}{1}} b_{2} - a_{{0}{0}} a_{{2}{1}} b_{1} - a_{{0}{1}} a_{{1}{0}} b_{2} + a_{{0}{1}} a_{{2}{0}} b_{1} + a_{{1}{0}} a_{{2}{1}} b_{0} - a_{{1}{1}} a_{{2}{0}} b_{0}}{a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}}\\right ]$$"
      ],
      "text/plain": [
       "⎡               a_{{0}{1}}⋅a_{{1}{2}}⋅b_{2} - a_{{0}{1}}⋅a_{{2}{2}}⋅b_{1} - a_\n",
       "⎢─────────────────────────────────────────────────────────────────────────────\n",
       "⎣a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{\n",
       "\n",
       "{{0}{2}}⋅a_{{1}{1}}⋅b_{2} + a_{{0}{2}}⋅a_{{2}{1}}⋅b_{1} + a_{{1}{1}}⋅a_{{2}{2}\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{\n",
       "\n",
       "}⋅b_{0} - a_{{1}{2}}⋅a_{{2}{1}}⋅b_{0}                              -(a_{{0}{0}\n",
       "────────────────────────────────────────────────────, ────────────────────────\n",
       "1}{0}}⋅a_{{2}{1}} - a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}  a_{{0}{0}}⋅a_{{1}{1}}⋅a_\n",
       "\n",
       "}⋅a_{{1}{2}}⋅b_{2} - a_{{0}{0}}⋅a_{{2}{2}}⋅b_{1} - a_{{0}{2}}⋅a_{{1}{0}}⋅b_{2}\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}}\n",
       "\n",
       " + a_{{0}{2}}⋅a_{{2}{0}}⋅b_{1} + a_{{1}{0}}⋅a_{{2}{2}}⋅b_{0} - a_{{1}{2}}⋅a_{{\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       " + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} - a_{{0\n",
       "\n",
       "2}{0}}⋅b_{0})                               a_{{0}{0}}⋅a_{{1}{1}}⋅b_{2} - a_{{\n",
       "───────────────────────────, ─────────────────────────────────────────────────\n",
       "}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}  a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{0}{0}}⋅a_{\n",
       "\n",
       "0}{0}}⋅a_{{2}{1}}⋅b_{1} - a_{{0}{1}}⋅a_{{1}{0}}⋅b_{2} + a_{{0}{1}}⋅a_{{2}{0}}⋅\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "{1}{2}}⋅a_{{2}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a_{{1}{2}}⋅\n",
       "\n",
       "b_{1} + a_{{1}{0}}⋅a_{{2}{1}}⋅b_{0} - a_{{1}{1}}⋅a_{{2}{0}}⋅b_{0}             \n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "a_{{2}{0}} + a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} - a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0\n",
       "\n",
       "  ⎤\n",
       "──⎥\n",
       "}}⎦"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[sp.combsimp(i) for i in xs.values()]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "综上，三元线性方程组的解表示为：${{x_0=\\frac{|A0|}{|A|},x_1=\\frac{|A1|}{|A|},x_2=\\frac{|A2|}{|A|}}}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.2.全排列及其逆序数\n",
    "把$n$个不同的元素排列成一列，叫做这$n$个元素的**全排列**。$n$个不同元素的所有排列的种数，通常用$P_n$表示,也就是$n$的阶乘$n!=n\\cdot (n-1)\\dots 3\\cdot 2\\cdot 1$。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFMAAAAVCAYAAAA6s9JxAAAABHNCSVQICAgIfAhkiAAAAwZJREFUWIXt2E2IllUUB/CfY00OjmhFEkRR4Vcw4UdhGegmB6Fo2UJxkbQRNMI2UQi5iAqRVm1yU0qooaIVBI0rhaLSUnMxSKCJ2NSEOFOGaeq0OPdh3nm8T/MOvOozMH+4HLj/c8499zznfj1M4KZjO/ox9XYHUkM8gSG83Izyk7iO11o0+FBq4wFLsRd9uJxkD54r6e1LXOdoDnswgI4WBThekrlRxPkHPsI72IrD2FzSXZx03/w/h3NEVW5tYZDjIZkvihgPYFqGvzPT14szmFzl9L3k9NkM1524d9GFHfgdF/ENnqrwWfdktuEU/sZ9Y7B7S8xrRaOjRizHNXybMV6Y5BxR+p3YhoNYgs/lv2rd8QwewZe4gOfxOl4V86rC10l258ipuIoTFca7xJfox6IStzdxSzN2da/MDSK+D/CT4XiLdlC+Yqcn/vuio7EyHxDrv69i0KIy1+DHEteb5JSM3ZDYh+uKmUmuFYfucrHCuvAVlmF3xm4Q/+ChnNMlYuKfZrhOsfzPYFKG35FsH60YdCA/j1pgs4j9GuaXuA6cTXxuyZ8TqxkjK/NSkrnqWpB0e+SX7CKRtNMZbjC1uuJCkqdwvMRdEtVJXIfK6DCctxHJ7E/y3oxRsUf+kOGmYTaOyid6EH9m+uuCk0lWrZ4i2eV7dxtmGM6bOxrIPnFhnZtxWOyXRyq4NvlEw+MV/XXBIbFUZ6MdV0p8V5K/lPrnii3vWJXjPaK6ZpX6j4vnVXvGpjgNV1X4nJdaM/g4+XqpSf1W4ZM07tul/m5xeA6IKmzEmmSzvsrpyqSwrqHvLvG1qiqvCCRX0YztarQ96a5uUr9VmImf09iHsEWc4Ffxr3ghlbEz8Q9WOW3Hb/iuoa/4S/JhhU0v/nLjA6DAWJJ5VOyvdzep30rcg/fFIXoF5/EZns7oThcHz/7RnL4hJr9wNMUWY4a4npR/KtQRr6h+pIzAFHGf/OJmR1TCC+ISfP8tHnes6MCv4nxpCsvEQ37i5/CNeAyb8PDtDWMCE2gW/wFUlrkZO4OCHgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left ( n!, \\quad 6\\right )$$"
      ],
      "text/plain": [
       "(n!, 6)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sp.factorial(n),sp.factorial(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA00AAAAVCAYAAACaNgUr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NmBmdH1Brct9UXfCR90JByl9pqg74SClzxR1Jxyk9Jmi7oSDlD5Tqtypqs1hMeYK7R3HmivrMR8ctaJuxY6R0ieY2yPOYN5TW0SX+6LuhI26ExZS+gR1JzSk9AnqTmhI6RPUndCQ0idUu1PnVSFrgE0U322iqqZ0y2rMy6kXdttGKepOuKg7ii/qjuKLuqP4ou4ovlS5E7pXiqIoiqIoiqIoiqIoiqIoiqIoikj+BQHK9fUD0KdVAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$\\left ( \\left ( 0, \\quad 1, \\quad 2\\right ), \\quad \\left ( 0, \\quad 2, \\quad 1\\right ), \\quad \\left ( 1, \\quad 0, \\quad 2\\right ), \\quad \\left ( 1, \\quad 2, \\quad 0\\right ), \\quad \\left ( 2, \\quad 0, \\quad 1\\right ), \\quad \\left ( 2, \\quad 1, \\quad 0\\right )\\right )$$"
      ],
      "text/plain": [
       "((0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0))"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tuple(itertools.permutations(range(xn),xn))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "所有6种不同的排法中，只有$(1,2,3)$中的数字是从小到大的自然顺序排列的，而其他排列中都有大的数排在小的数之前。\n",
    "\n",
    ">**定义**：对于$n$个不同的元素，从小到大的排序为标准次序-**顺序**，当某两个元素的先后次序与标准次序不同时，就称这两个元素组成一个**逆序**。\n",
    "\n",
    "例如，在排列$(3,2,5,1,4)$中，$(3,2),(3,1),(2,1),(5,1)和(5,4)$都是逆序。\n",
    ">**定义**:排列中所有逆序的总数称为此排列的**逆序数**\n",
    "\n",
    "排列$(i_0,i_1,\\dots,i_n)$的逆序数通常记为$t(i_0,i_1,\\dots,i_n)$。逆序数为奇数的排列为**奇排列**，逆序数为偶数的排列为**偶排列**。特别的，符合标准次序的排列是偶排列。\n",
    "\n",
    "计算排列的逆序数的方法：\n",
    ">设$(i_0,i_1,\\dots,i_n)$是$(0,1,2,\\dots,n)$这$n+1$个自然数的任一排列，并规定由小到大为标准次序。依次计算$i_0到i_n$,有多少个比$i_x$大的数排在$i_x$前面，记为$t_x$,则此排列的逆序数$t=\\sum_{x=0}^nt_x$;"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.3.$n$阶行列式的定义\n",
    "## 1.3.1.$3$阶行列式\n",
    "对于矩阵$A$的行列式表示为：$|A|$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( \\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right], \\quad a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}\\right )$$"
      ],
      "text/plain": [
       "⎛⎡a_{{0}{0}}  a_{{0}{1}}  a_{{0}{2}}⎤                                         \n",
       "⎜⎢                                  ⎥                                         \n",
       "⎜⎢a_{{1}{0}}  a_{{1}{1}}  a_{{1}{2}}⎥, a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{\n",
       "⎜⎢                                  ⎥                                         \n",
       "⎝⎣a_{{2}{0}}  a_{{2}{1}}  a_{{2}{2}}⎦                                         \n",
       "\n",
       "                                                                              \n",
       "                                                                              \n",
       "0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a\n",
       "                                                                              \n",
       "                                                                              \n",
       "\n",
       "                                                                              \n",
       "                                                                              \n",
       "_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} - a_{{0}{2}}⋅a_{{1}{1}\n",
       "                                                                              \n",
       "                                                                              \n",
       "\n",
       "            ⎞\n",
       "            ⎟\n",
       "}⋅a_{{2}{0}}⎟\n",
       "            ⎟\n",
       "            ⎠"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa,xa.det()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    ">总结规律如下：\n",
    "1. 三阶行列式共有6项，即$3!$项；\n",
    "2. 每一项都是位于不同行不同列的三个元素的乘积；\n",
    "3. 每一项都可以写成$a_{0i_0}a_{1i_1}a_{2i_2}$（正负号除外），其中$i_0i_1i_2$是$1,2,3$的某个排列；\n",
    "4. 当$i_0i_1i_2$是偶排列时，对应的项取正号，反之取负号；\n",
    "\n",
    "所以，三阶行列式可以写成$|A|=\\sum_{i_0i_1i_2}{{(-1)}^{t{(i_0i_1i_2)}}a_{0i_0}a_{1i_1}a_{2i_2}}$，其中$\\sum_{i_0i_1i_2}$表示对$1,2,3$的所有排列求和。\n",
    "\n",
    "二阶行列式有上述类似的规律。下面将行列式推广到一般的情形。\n",
    "### 1.3.2.$n$阶行列式\n",
    "$n$阶行列式$\\large |A|=\\sum_{i_0i_1\\dots i_{n-1}}{{(-1)}^{t{(i_0i_1\\dots i_{n-1})}}a_{0i_0}a_{1i_1}\\dots a_{n-1i_{n-1}}}$\n",
    "特征如下：\n",
    ">1. $n阶$行列式共有$n!$项；\n",
    "2. 每一项都是位于不同行不同列的$n$个元素的乘积；\n",
    "3. 每一项都可以写成$a_{0i_0}a_{1i_1}\\dots a_{n-1i_{n-1}}$（正负号除外）,其中$i_0i_1\\dots i_{n-1}$是$0,1,2,\\dots ,(n-1)$的某个排列；\n",
    "4. 当$i_0i_1\\dots i_{n-1}$是偶排列时，对应的项取正号，反之取负号；\n",
    "\n",
    "特例，对于$|-1|$可以有两种解释：\n",
    ">1. 若理解称绝对值，则$|-1|=+1$;\n",
    "2. 若理解称一阶行列式，则$|-1|=-1$。\n",
    "\n",
    "### 1.3.3.特殊行列式\n",
    "1. 对角行列式：对角矩阵以及斜对角矩阵的行列式称为对角行列式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( \\left[\\begin{matrix}a_{0} & 0 & 0\\\\0 & a_{1} & 0\\\\0 & 0 & a_{2}\\end{matrix}\\right], \\quad a_{0} a_{1} a_{2}\\right )$$"
      ],
      "text/plain": [
       "⎛⎡a_{0}    0      0  ⎤                   ⎞\n",
       "⎜⎢                   ⎥                   ⎟\n",
       "⎜⎢  0    a_{1}    0  ⎥, a_{0}⋅a_{1}⋅a_{2}⎟\n",
       "⎜⎢                   ⎥                   ⎟\n",
       "⎝⎣  0      0    a_{2}⎦                   ⎠"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xn=3\n",
    "xa=sp.diag(*getM('a',xn,1))\n",
    "xa,xa.det()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( \\left[\\begin{matrix}0 & 0 & a_{0}\\\\0 & a_{1} & 0\\\\a_{2} & 0 & 0\\end{matrix}\\right], \\quad - a_{0} a_{1} a_{2}\\right )$$"
      ],
      "text/plain": [
       "⎛⎡  0      0    a_{0}⎤                    ⎞\n",
       "⎜⎢                   ⎥                    ⎟\n",
       "⎜⎢  0    a_{1}    0  ⎥, -a_{0}⋅a_{1}⋅a_{2}⎟\n",
       "⎜⎢                   ⎥                    ⎟\n",
       "⎝⎣a_{2}    0      0  ⎦                    ⎠"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa[:,::-1],xa[:,::-1].det()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2. 上三角行列式(主对角下侧元素都为0)\n",
    "\n",
    "$|A|=\\prod_{i=0}^na_{ii}$\n",
    "3. 下三角行列式(主对角上侧元素都为0)\n",
    "\n",
    "$|A|=\\prod_{i=0}^na_{ii}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.4.对换\n",
    "### 1.4.1.定义\n",
    ">在排列中，将任意两个元素对调，其余的元素不动，这种作出新排列的行为叫做**对换**。特别的，将相邻两个元素对换，叫做**相邻对换**。<br>特性：<br>\n",
    "1. 相邻对换是对换的特殊情形；\n",
    "2. 一般的对换可以通过一系列的相邻对换来实现；\n",
    "3. 如果连续施行两次相同的对换，那么排列就被还原了。\n",
    "### 1.4.2.对换和排列奇偶性的关系\n",
    ">1. 定理1，对换改变元素的奇偶性；\n",
    "2. 推论，奇排列变成标准排列的对换次数为奇数，偶排列变成标准排列的对换次数为偶数；\n",
    "3. 定理2,$n$阶行列式也可定义为$\\large |A|=\\sum_{i_0i_1\\dots i_{n-1}}{{(-1)}^{t{(i_0i_1\\dots i_{n-1})}}a_{i_00}a_{i_11}\\dots a_{i_{n-1}n-1}}$;\n",
    "4. 定理3,$n$阶行列式也可定义为$\\large |A|=\\sum_{\\begin{pmatrix} i_0i_1\\dots i_{n-1}\\\\ j_0j_1\\dots j_{n-1}\\end{pmatrix}}{{(-1)}^{t{(i_0i_1\\dots i_{n-1})}+t{(j_0j_1\\dots j_{n-1})}}a_{i_0j_0}a_{i_1j_1}\\dots a_{i_{n-1}j_{n-1}}}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.5.行列式的性质\n",
    "### 1.5.1.性质\n",
    "记行列式$D=|A|,D^T=|A^T|$,其中行列式$D^T$为行列式$D$的**转置行列式**。若记$D=det(a_{ij}),D^T=det(b_{ij}),则b_{ij}=a_{ji}$。\n",
    "#### 1.5.1.1.性质1\n",
    "行列式与它的转置行列式相等。<br>\n",
    "证明，根据行列式的定义，有<br>\n",
    "$\\large D^T\\\\=\\sum_{i_0i_1\\dots i_{n-1}}{{(-1)}^{t{(i_0i_1\\dots i_{n-1})}}b_{0i_0}\\dots b_{n-1i_{n-1}}}\\\\=\\sum_{i_0i_1\\dots i_{n-1}}{{(-1)}^{t{(i_0i_1\\dots i_{n-1})}}a_{i_00}\\dots a_{i_{n-1}n-1}}\\\\=D$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{0}{0}}  a_{{0}{1}}  a_{{0}{2}}⎤\n",
       "⎢                                  ⎥\n",
       "⎢a_{{1}{0}}  a_{{1}{1}}  a_{{1}{2}}⎥\n",
       "⎢                                  ⎥\n",
       "⎣a_{{2}{0}}  a_{{2}{1}}  a_{{2}{2}}⎦"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xn=3\n",
    "xa=getM('a',xn,xn)\n",
    "xa"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABXIAAAAXCAYAAACms7fWAAAABHNCSVQICAgIfAhkiAAACq9JREFUeJztnV3IHUcZx39J2tKQSFOsVEXrB1JoEUlRpCIphyKKF0VBpeiFHD9urHoj3lQQpTeKIkTBXlTE16JQwaLSC0WKRanSKlGL4EdVTBVr00ArVogfbeLF7LEnmz1nZ2bn2Zkz8//BIcnus/PM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IutZ6jC9Jr6tNmzhwFm7k0B2P9torrYkO7e4H9C6X2NRfyaLrY0OZeoE0MtefoEKXWSr42odS+r0IeTReUvbf69K9UWqt/a8/RkvXMmaOwu3trqbWST99iaH3NtcqTxYZ29wJtYvAZk89cuqa75qUT+yOEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQiTjf5hzbc99m05gAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$\\left ( a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}, \\quad a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}\\right )$$"
      ],
      "text/plain": [
       "(a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{\n",
       "1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{\n",
       "1}{0}}⋅a_{{2}{1}} - a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}, a_{{0}{0}}⋅a_{{1}{1}}⋅a_\n",
       "{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}}\n",
       " + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} - a_{{0\n",
       "}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}})"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa.det(),xa.T.det()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa.det() is xa.T.det()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "行列式中行与列具有同等的地位，行列式的性质凡是对行成立的对列也同样成立。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 1.5.1.2.性质2\n",
    "互换行列式的两行(列),行列式变号。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( \\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right], \\quad \\left[\\begin{matrix}a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right]\\right )$$"
      ],
      "text/plain": [
       "⎛⎡a_{{0}{0}}  a_{{0}{1}}  a_{{0}{2}}⎤  ⎡a_{{1}{0}}  a_{{1}{1}}  a_{{1}{2}}⎤⎞\n",
       "⎜⎢                                  ⎥  ⎢                                  ⎥⎟\n",
       "⎜⎢a_{{1}{0}}  a_{{1}{1}}  a_{{1}{2}}⎥, ⎢a_{{0}{0}}  a_{{0}{1}}  a_{{0}{2}}⎥⎟\n",
       "⎜⎢                                  ⎥  ⎢                                  ⎥⎟\n",
       "⎝⎣a_{{2}{0}}  a_{{2}{1}}  a_{{2}{2}}⎦  ⎣a_{{2}{0}}  a_{{2}{1}}  a_{{2}{2}}⎦⎠"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa_=xa.copy()\n",
    "xa_[0,:],xa_[1,:]=xa_[1,:],xa_[0,:]\n",
    "xa,xa_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABYoAAAAXCAYAAAClKHu7AAAABHNCSVQICAgIfAhkiAAACqtJREFUeJztnU2oJUcVx38z+SDDjCTBSFQ0fiCBBJEJikRkwiWI4iIoqARdSPuxMepG3EQQJRtFEUbBLCLiMyhEMKhkoUgwKFESZdQgRI2KL4pjJgOJGCF+JDMuqq/e6el7u6q7Tld11f8Hl2S6q+tUnX+dU6fv69cPhBBCCCGEEEIIIYQQQoge7gQeBw6nHogQQgghhBBCCCGEEEKIKLwaOAu8z6fxa4AzwEcsRySEEEIIIYQQQgghhBBidr4F/BU4MtTw+8DfgEPWIxJCCCGEEEIIIYQQQggxK6/FPVX8sV2NrsY9TXzHHCMSQojCaXCJd5V2GCISDdJTCCFKp0G5vjQapKkQQsxFg3Lukvg18ChwwfrAwU6D9wIHgG9s6eBdwNeBR4CngCeBnwHviT1S2Z6NVHOTnjbU6NeS9YQ6/VqypjX6VXrKthimxvgseR3V6FfpKdtLosY4kZ5l2S5ZT6jTr6ls3wVcBbxhfeCCToNPA1cCHwL+0zn3HOAB4GngBHAf8CfgeuCdwD+BH1uMumLb1qSam/S0oUa/5q7nUeCtwFeB/RHX1+jXnDVdqp4pbees51Rq1DO17VKpMT5zXkfK9cux68sUTWvUM7Vta2qME+lZlu3c9VzqPlrjWgK4CHg3cAr3KuJzOAw8A/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6XTNnjOby6glQfW1xD7xtfCE05LOPbqL6+ny/XIr7I3bfHhg/t7aDuW6o4QAPAnd0jj3CuX/Mbtf5GEwVbAxfYDj4fNrkho9eKTW18mlIvym/tAglVCuruW3r13It1Ryjm1houqvPVDE6R16ywHfc1mt17hgtNedCHprmWBf5+OUy3JMOn4k4rqWSQz2W4zrybZMbOegJ8+/fyvUO1df5k0N9PdRvihhVfT2NXGN0zZLybg6a5lgX+frlw+3Yjg0ZvAR4FLgnaJjnczPwb+D9uJcjHwf+AbzE8/xYjgBH289Z4KPt/18V2GYMt+OedrkR9+6P9edIYJsc8dErlaZWPvXp12otWeOjldXcfPq1Wku1x6iFpj59poxRq7Vkjc+4rfyaKkZLzrmQTtPc6yIfv9yE+5W7Od99mCup6rHc11HJe3fKeyYLv9ae61VflxejKTVNFaOqr8PJPUaXmndVX4+P0UPASeCbvoZvAD4BHB4/dgBuAfaBfwEn2n5Dzo9hhROh+9kLbDOGvj7PAp8MbJMrPnql0NTKpz79Do0tZ4a0WmEzN99+LdZS7TG6Ir6mPn2mjFGwWUtzMDRuK7+utvS7Fzi+UErPuZBG09WWPvcC24yh9BhNRYp6bEXe66jkvdu3TSgr0uzftef6FTZz8+1X9XU4Od8zpYpRWO7eXVt9zRa7JeVd1dfjYvSa9pqXThyPEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghCuG/+ymJbyYh0M8AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\left ( a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}, \\quad - a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} + a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} + a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} - a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} - a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} + a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}\\right )$$"
      ],
      "text/plain": [
       "(a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{\n",
       "1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{\n",
       "1}{0}}⋅a_{{2}{1}} - a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}, -a_{{0}{0}}⋅a_{{1}{1}}⋅a\n",
       "_{{2}{2}} + a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} + a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}\n",
       "} - a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} - a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} + a_{{\n",
       "0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}})"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa.det(),xa_.det()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAABHNCSVQICAgIfAhkiAAAAM5JREFUOI3N0rEyQ0EUxvEfJcMVWhoZ8Qpq75PnoDJ0Kl5BK0U67yAUiUYmpZGYoRDNuePOkXszYxS+5ps95/x3Z3c//lC7uMIz3jHCOVpNUBsTzHGDU/RjfY+dOvA2hrqpfhb1y0XQfjSHWE29DUwxw7o0cBzew2cCX3GHNRxl8DD8oeYaj+GdDBbhLzVgWd/K4DKthM8zWO5YWKzN6lwVHIR3asCD8B9v0Lb8O97Ed2T9KgDlqdXInfiO3EBD5GAP1xjjA0+4wHYT9I/1BRgnMa7SDNsAAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$0$$"
      ],
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa.det()+xa_.det()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**推论**：如果行列式有两行或者两列完全相同，则此行列式为零。<br>\n",
    "**证明**:互换相同的两行，有$D=-D$,所有$D=0$。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 1.5.1.3.性质3\n",
    "行列式的某一行(列)中所有的元素都乘以同一个倍数$k$，等于数$k$乘以此行列式。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( \\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right], \\quad \\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\3 a_{{1}{0}} & 3 a_{{1}{1}} & 3 a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right]\\right )$$"
      ],
      "text/plain": [
       "⎛⎡a_{{0}{0}}  a_{{0}{1}}  a_{{0}{2}}⎤  ⎡ a_{{0}{0}}    a_{{0}{1}}    a_{{0}{2}\n",
       "⎜⎢                                  ⎥  ⎢                                      \n",
       "⎜⎢a_{{1}{0}}  a_{{1}{1}}  a_{{1}{2}}⎥, ⎢3⋅a_{{1}{0}}  3⋅a_{{1}{1}}  3⋅a_{{1}{2\n",
       "⎜⎢                                  ⎥  ⎢                                      \n",
       "⎝⎣a_{{2}{0}}  a_{{2}{1}}  a_{{2}{2}}⎦  ⎣ a_{{2}{0}}    a_{{2}{1}}    a_{{2}{2}\n",
       "\n",
       "} ⎤⎞\n",
       "  ⎥⎟\n",
       "}}⎥⎟\n",
       "  ⎥⎟\n",
       "} ⎦⎠"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa_=xa.copy()\n",
    "xa_[1,:]=xa_[1,:]*xn\n",
    "xa,xa_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAu8AAAAWCAYAAABwgXKpAAAABHNCSVQICAgIfAhkiAAAB05JREFUeJztnUuIHEUYgL/EB0JWSEziGvCBgqAhSBQPgiQOOelBVFCCHmQEPRivueQghoCIBDEK7kERoyioIAoeFPGBr5AoeV1EI+JiIGSNJvgANT7WQ/WQntqe6aru+qtqev8PluzM/lt/d/9f/zWzXdMBRVEURVEURVEmkseBD4CjwB/ASeAg8AiwMuF2KfFQBxR1QFEHFHVAUQcyZYn1+DRwAPgK+BFYBtwAXA8cK74/GnMDleioA4o6oKgDijqgqAMTwnkjnn8UmAdmIm6LkgZ1QFEHJp8+pla9hr+vDkw+fdQBpR3qQKYstR7/OSLu9eLfKyt+dg/wCnAE+A04BXwJ3BdiA2tIlTvlPkujDkxGbknUgcnILUkTB2Bx9mR1YBh1QB1YjLWImvcsx7gHgE3AW8B7pefPB/Zi1kLtBz4CfsBcSrkbU/jPQ22sRarcKfc5JepAPrlToQ7kk7uO9cDtwIvAbMBxRzkAi7MnqwPDqAN5OSBFjg6kzJ2NA1uB7cCTwKeYyyOHgdVW3BRwUcXvr8G88/habhOT5U65zzFRB/LNHQt1IN/cdfRpt2RigKsDsDh7sjowjDoQN3csJsGBlLmzceA4pjiDr3eAac8xvsF8wCEFqXKn3OfQqAOTmTsk6sBk5oZwL9xCO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b+lv9h/jtde+3VvPV4ScVzdTFNc7clRN6dmA9AbMBcJmkaI0UMB6C9BzEcGFWHtrlT1teFnBwYh6QD0j2oS30AZOeDcXS1D7Q9LiHI0YGqYybtgOQ81KW5ANI50CZ3W7LoA+swf5Y/BPyEebfwC2ZR/XbgAit+NebDCicw97Hcg1mYf22R4PlSbMhlM765bdqsbWqT9wnMO6e1LWMkkXQAwnog6UBdHZrmdq1vykulOThgI3E+tlk20yZ3rD7Qp/mSCV8HIPx8YCPhwLhxIX4fyGnZTG4OjKuFhAPS81AX5wJI54BvbpsUrwtj9YHW7AOetZ47wsIPKtbFtKVNkZryNPUnqktMF8jBg3H1laqDz7g5r3MMgW99JY7HqDEl3dM+cIYcHBg3bqo+EGMOzAXXfZU+J2L3Ap0LzpC7A74xrkxUH9gMnAbuB67GrPP5HbjMM6YJU5jbZq3HFGBr8f2lnjFNmMHcz3MTZr3S4GvKM6YrpPLApb5SdXAZV8q/HHGpr8TxcBlTqgdpHxgmlQMu46bsA1L+5YjLvkrVIlUv0LlgmNwdkKjFRPaBLZj7zf6Fuen8xoYxvvQwB97+2u0Z04SqMecxl518YrpECg961NdXqg4u47psX5eoq2+P8MfDdUyJHqR9YCEpHHAZN2UfABn/cqVuX6Vq0Rsx7m7P7fNF54KF5OyAS4wv2gcURVEURVEURVEURVEURVEURVEURVEURVEURVEURVEURVGUTvM/rfPB8cTL4HQAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$3 a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - 3 a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - 3 a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + 3 a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + 3 a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - 3 a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}$$"
      ],
      "text/plain": [
       "3⋅a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - 3⋅a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - 3⋅a_\n",
       "{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + 3⋅a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + 3⋅a_{{0}\n",
       "{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} - 3⋅a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa_.det()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAABHNCSVQICAgIfAhkiAAAAOlJREFUOI3N0r1KQ0EQBeDPkEJQEIyg2AipLARBUlgINhY2Fj6Eb2CvjUWw1ldJEdIIVkIiIoJFqoCIf2AliiEWu4vhcpV7wcKBZYbZOcw5h+GPookOBnjDC3o4QG18cCID/EAXN3jAFNbRwF2sB3kbJ39gcoQRTstKWI3AdmpUCgJ3Yr5KjazGFPuYxoygbyOCtvD424b7SC29FuYLsiMO7+JWcHWtDBiW8I7rskDCIYwwR3FXYTHmYfZjGQs5gIrvAzhPzerYwDaOcYY+ngVzNlEXnN7Lo7KCE1ziCZ94xQUOMVtQ0n+LLxK6LQuL4DX5AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$3$$"
      ],
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sp.simplify(xa_.det()/xa.det())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**推论**：行列式的某一行（列）中所有元素的公因子可以提到行列式符号的外面。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 1.5.1.4.性质4\n",
    "行列式中如果有两行（列）元素成比例，则此行列式为零。通过性质2的推论和性质3，容易证明。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( \\left[\\begin{matrix}3 a_{{2}{0}} & 3 a_{{2}{1}} & 3 a_{{2}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right], \\quad 0\\right )$$"
      ],
      "text/plain": [
       "⎛⎡3⋅a_{{2}{0}}  3⋅a_{{2}{1}}  3⋅a_{{2}{2}}⎤   ⎞\n",
       "⎜⎢                                        ⎥   ⎟\n",
       "⎜⎢ a_{{1}{0}}    a_{{1}{1}}    a_{{1}{2}} ⎥, 0⎟\n",
       "⎜⎢                                        ⎥   ⎟\n",
       "⎝⎣ a_{{2}{0}}    a_{{2}{1}}    a_{{2}{2}} ⎦   ⎠"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa_=xa.copy()\n",
    "xa_[0,:]=xa_[2,:]*xn\n",
    "xa_,xa_.det()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 1.5.1.5.性质5\n",
    "若行列式的某一列（行）的元素都是两数之和，如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( \\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right], \\quad \\left[\\begin{matrix}a_{{0}{0}} & b_{0} & a_{{0}{2}}\\\\a_{{1}{0}} & b_{1} & a_{{1}{2}}\\\\a_{{2}{0}} & b_{2} & a_{{2}{2}}\\end{matrix}\\right], \\quad \\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} + b_{0} & a_{{0}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} + b_{1} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} + b_{2} & a_{{2}{2}}\\end{matrix}\\right]\\right )$$"
      ],
      "text/plain": [
       "⎛⎡a_{{0}{0}}  a_{{0}{1}}  a_{{0}{2}}⎤  ⎡a_{{0}{0}}  b_{0}  a_{{0}{2}}⎤  ⎡a_{{0\n",
       "⎜⎢                                  ⎥  ⎢                             ⎥  ⎢     \n",
       "⎜⎢a_{{1}{0}}  a_{{1}{1}}  a_{{1}{2}}⎥, ⎢a_{{1}{0}}  b_{1}  a_{{1}{2}}⎥, ⎢a_{{1\n",
       "⎜⎢                                  ⎥  ⎢                             ⎥  ⎢     \n",
       "⎝⎣a_{{2}{0}}  a_{{2}{1}}  a_{{2}{2}}⎦  ⎣a_{{2}{0}}  b_{2}  a_{{2}{2}}⎦  ⎣a_{{2\n",
       "\n",
       "}{0}}  a_{{0}{1}} + b_{0}  a_{{0}{2}}⎤⎞\n",
       "                                     ⎥⎟\n",
       "}{0}}  a_{{1}{1}} + b_{1}  a_{{1}{2}}⎥⎟\n",
       "                                     ⎥⎟\n",
       "}{0}}  a_{{2}{1}} + b_{2}  a_{{2}{2}}⎦⎠"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xb_=xa.copy()\n",
    "xb_[:,1]=xb\n",
    "xa_=xa.copy()\n",
    "xa_[:,1]=xa_[:,1]+xb_[:,1]\n",
    "xa,xb_,xa_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "则："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAABHNCSVQICAgIfAhkiAAAAM5JREFUOI3N0rEyQ0EUxvEfJcMVWhoZ8Qpq75PnoDJ0Kl5BK0U67yAUiUYmpZGYoRDNuePOkXszYxS+5ps95/x3Z3c//lC7uMIz3jHCOVpNUBsTzHGDU/RjfY+dOvA2hrqpfhb1y0XQfjSHWE29DUwxw7o0cBzew2cCX3GHNRxl8DD8oeYaj+GdDBbhLzVgWd/K4DKthM8zWO5YWKzN6lwVHIR3asCD8B9v0Lb8O97Ed2T9KgDlqdXInfiO3EBD5GAP1xjjA0+4wHYT9I/1BRgnMa7SDNsAAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$0$$"
      ],
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sp.simplify(xa_.det()-(xa.det()+xb_.det()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**验证：**以三阶行列式为例<br>\n",
    "$\\large D\\\\=\\sum_{i_0i_1i_{2}}{{(-1)}^{t{(i_0i_1i_{3})}}a_{0i_0}(a_{1i_1}+b_{1i_1}) a_{2i_{2}}}\\\\=\\sum_{i_0i_1i_{2}}{{(-1)}^{t{(i_0i_1i_{3})}}a_{0i_0}(a_{1i_1})a_{2i_{2}}}+\\sum_{i_0i_1i_{2}}{{(-1)}^{t{(i_0i_1i_{3})}}a_{0i_0}(b_{1i_1})a_{2i_{2}}}\\\\=D_a+D_b$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 1.5.1.6.性质6\n",
    "把行列式的某一列（行）的各元素乘以同一个倍数然后加到另一列（行）对应的元素上去，行列式不变。如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{0}{0}} + 3 a_{{2}{0}} & a_{{0}{1}} + 3 a_{{2}{1}} & a_{{0}{2}} + 3 a_{{2}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{0}{0}} + 3⋅a_{{2}{0}}  a_{{0}{1}} + 3⋅a_{{2}{1}}  a_{{0}{2}} + 3⋅a_{{2}{2\n",
       "⎢                                                                             \n",
       "⎢       a_{{1}{0}}                 a_{{1}{1}}                 a_{{1}{2}}      \n",
       "⎢                                                                             \n",
       "⎣       a_{{2}{0}}                 a_{{2}{1}}                 a_{{2}{2}}      \n",
       "\n",
       "}}⎤\n",
       "  ⎥\n",
       "  ⎥\n",
       "  ⎥\n",
       "  ⎦"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa_=xa.copy()\n",
    "xa_[0,:]=xa_[0,:]+xa_[2,:]*xn\n",
    "xa_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAABHNCSVQICAgIfAhkiAAAAM5JREFUOI3N0rEyQ0EUxvEfJcMVWhoZ8Qpq75PnoDJ0Kl5BK0U67yAUiUYmpZGYoRDNuePOkXszYxS+5ps95/x3Z3c//lC7uMIz3jHCOVpNUBsTzHGDU/RjfY+dOvA2hrqpfhb1y0XQfjSHWE29DUwxw7o0cBzew2cCX3GHNRxl8DD8oeYaj+GdDBbhLzVgWd/K4DKthM8zWO5YWKzN6lwVHIR3asCD8B9v0Lb8O97Ed2T9KgDlqdXInfiO3EBD5GAP1xjjA0+4wHYT9I/1BRgnMa7SDNsAAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$0$$"
      ],
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sp.simplify(xa.det()-xa_.det())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "基于**性质5**和**性质4**，可以得到证明。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.5.2.行列式的应用\n",
    "计算行列式常用的方法：利用行列式性质的不变性，可以把行列式转化为上三角行列式，从而较容易的获得行列式的值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}2 & 3 & 3\\\\4 & 2 & 2\\\\2 & 3 & 1\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡2  3  3⎤\n",
       "⎢       ⎥\n",
       "⎢4  2  2⎥\n",
       "⎢       ⎥\n",
       "⎣2  3  1⎦"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# aa=sp.Matrix(np.random.randint(low=0,high=5,size=(3,3)))\n",
    "aa=sp.Matrix([[2,3,3],[4,2,2],[2,3,1]])\n",
    "aa"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}2 & 3 & 3\\\\4 & 2 & 2\\\\2 & 3 & 1\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡2  3  3⎤\n",
       "⎢       ⎥\n",
       "⎢4  2  2⎥\n",
       "⎢       ⎥\n",
       "⎣2  3  1⎦"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ab=aa.copy()\n",
    "ab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}0 & 0 & 2\\\\4 & 2 & 2\\\\2 & 3 & 1\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡0  0  2⎤\n",
       "⎢       ⎥\n",
       "⎢4  2  2⎥\n",
       "⎢       ⎥\n",
       "⎣2  3  1⎦"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ab[0,:]=ab[0,:]-ab[2,:]\n",
    "ab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}0 & 0 & 2\\\\4 & 2 & 0\\\\2 & 3 & 1\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡0  0  2⎤\n",
       "⎢       ⎥\n",
       "⎢4  2  0⎥\n",
       "⎢       ⎥\n",
       "⎣2  3  1⎦"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ab[1,:]=ab[1,:]-ab[0,:]\n",
    "ab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}0 & 0 & 2\\\\4 & 2 & 0\\\\2 & 3 & 0\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡0  0  2⎤\n",
       "⎢       ⎥\n",
       "⎢4  2  0⎥\n",
       "⎢       ⎥\n",
       "⎣2  3  0⎦"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ab[2,:]=ab[2,:]-1/2*ab[0,:]\n",
    "ab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}0 & 0 & 2\\\\0 & -4 & 0\\\\2 & 3 & 0\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡0  0   2⎤\n",
       "⎢        ⎥\n",
       "⎢0  -4  0⎥\n",
       "⎢        ⎥\n",
       "⎣2  3   0⎦"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ab[1,:]=ab[1,:]-2*ab[2,:]\n",
    "ab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}0 & 0 & 2\\\\0 & -4 & 0\\\\2 & 0 & 0\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡0  0   2⎤\n",
       "⎢        ⎥\n",
       "⎢0  -4  0⎥\n",
       "⎢        ⎥\n",
       "⎣2  0   0⎦"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ab[2,:]=ab[2,:]+3/4*ab[1,:]\n",
    "ab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}-2 & 0 & 0\\\\0 & 4 & 0\\\\0 & 0 & -2\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡-2  0  0 ⎤\n",
       "⎢         ⎥\n",
       "⎢0   4  0 ⎥\n",
       "⎢         ⎥\n",
       "⎣0   0  -2⎦"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ab=-ab[[2,1,0],:]\n",
    "ab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABsAAAASCAYAAACq26WdAAAABHNCSVQICAgIfAhkiAAAAVxJREFUOI3t1DFLXEEUBeDPJQpbSCDoYhcEhRQrYqGooGxAEWKTgGn8Bf4ASwmCnYWNf8FG1EIQ0aTbEAJbCCnTrEICIcSgESUqBi3ePFgeu+6TXUjjheHAPefOmfvmvuE/xgxW8RFnuMVairoxbOEHrgK+x6tK0ZNE0QL6cY7veJHCaAFLOMZOMOrAAArYrVX4Er1oCcJ6nb0Nmg9or8K3pjgsKcwyKOMCnWk2TH7Gh8QourGJE0wjj0uU8LmZZoMBf+IAfQm+KBq4X3Ei04BZLuAcspgQ3Vse+xjHRtrNCu6/s+XA/xNNcGVk8S3wI3Gykc5OApbxJcH9FXUHQ80w+xrwtM5hss0wK+JG9F+2VeHzAY+aYXaMdTzFuwQ3iSn8wV6cbEmIXocFXaGgLHorY4P5Cn0On9ATNCU8xxvRcMy6ZyIXg6jWOqpS8wwrOMQ1fmMbw7VMHqOhuAOxLk9bTfXHbwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$16$$"
      ],
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ab[0,0]*ab[1,1]*ab[2,2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABsAAAASCAYAAACq26WdAAAABHNCSVQICAgIfAhkiAAAAVxJREFUOI3t1DFLXEEUBeDPJQpbSCDoYhcEhRQrYqGooGxAEWKTgGn8Bf4ASwmCnYWNf8FG1EIQ0aTbEAJbCCnTrEICIcSgESUqBi3ePFgeu+6TXUjjheHAPefOmfvmvuE/xgxW8RFnuMVairoxbOEHrgK+x6tK0ZNE0QL6cY7veJHCaAFLOMZOMOrAAArYrVX4Er1oCcJ6nb0Nmg9or8K3pjgsKcwyKOMCnWk2TH7Gh8QourGJE0wjj0uU8LmZZoMBf+IAfQm+KBq4X3Ei04BZLuAcspgQ3Vse+xjHRtrNCu6/s+XA/xNNcGVk8S3wI3Gykc5OApbxJcH9FXUHQ80w+xrwtM5hss0wK+JG9F+2VeHzAY+aYXaMdTzFuwQ3iSn8wV6cbEmIXocFXaGgLHorY4P5Cn0On9ATNCU8xxvRcMy6ZyIXg6jWOqpS8wwrOMQ1fmMbw7VMHqOhuAOxLk9bTfXHbwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$16$$"
      ],
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aa.det()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.5.3.小结\n",
    "行列式的6个性质（行列式中行与列具有同等的地位，凡是对行成立的性质对列也同样成立）。\n",
    "\n",
    "计算行列式常用方法：\n",
    "1. 利用定义；\n",
    "2. 利用性质把行列式化为上三角形行列式，从而算得行列式的值。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.6.行列式按行（列）展开\n",
    "### 1.6.1. 引子"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{0}{0}}  a_{{0}{1}}  a_{{0}{2}}⎤\n",
       "⎢                                  ⎥\n",
       "⎢a_{{1}{0}}  a_{{1}{1}}  a_{{1}{2}}⎥\n",
       "⎢                                  ⎥\n",
       "⎣a_{{2}{0}}  a_{{2}{1}}  a_{{2}{2}}⎦"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xn\n",
    "xa=getM('a',xn,xn)\n",
    "xa"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAoYAAAAXCAYAAACWL462AAAABHNCSVQICAgIfAhkiAAAB+pJREFUeJztnUmoHFUUhr84kZCIcSKOcUAFg0hEkYgYGhFdiS4MQRfSDhunjbhREEM2iiJEQReKGKOCgqLiQhFRlCiJoiiCI+JTMTEGEjVCnOJzcauwra6ue+5Ut6r7fNAkr/v0PcM9f9/bVfXqgaIoiqIoiqJ0kE3AT8Di3IEoU8nZwDxwXe5AMqM6U7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RpmQh5g85vxwY1xLMbQpWYhK+rfj/ckcbHx7GHP69EHMuv3wscbTpIpKapcrNNq50PhdhblvwXGA8bWLTkGsvx9JZDCSxu3yGSJlmnYK9rrl0CvL57JtWJXm51D2mTm39kEJjIMs31Vqcmq7vMyRzmkxjN2LuD/UH5gaKqz1tSlYDd2Hu/+PLADMJ1cdGRxsf6sacB9Y52nSRAfaapcrNNq4kNjACWQecGBhP2zRpaIB7L8fQWQwGyGJ3+QyRMM06BXtdc+m0RDKffdSqLS/XusfS6WCC340OsfsgyVcSWxcZ0O19BtjntI8aUxRFURRFURRFURRFURRFURRFURRFURRFURRFURQlI/8CCN5E0WcN1rEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$a_{{0}{0}} \\left(a_{{1}{1}} a_{{2}{2}} - a_{{1}{2}} a_{{2}{1}}\\right) + a_{{0}{1}} \\left(- a_{{1}{0}} a_{{2}{2}} + a_{{1}{2}} a_{{2}{0}}\\right) + a_{{0}{2}} \\left(a_{{1}{0}} a_{{2}{1}} - a_{{1}{1}} a_{{2}{0}}\\right)$$"
      ],
      "text/plain": [
       "a_{{0}{0}}⋅(a_{{1}{1}}⋅a_{{2}{2}} - a_{{1}{2}}⋅a_{{2}{1}}) + a_{{0}{1}}⋅(-a_{{\n",
       "1}{0}}⋅a_{{2}{2}} + a_{{1}{2}}⋅a_{{2}{0}}) + a_{{0}{2}}⋅(a_{{1}{0}}⋅a_{{2}{1}}\n",
       " - a_{{1}{1}}⋅a_{{2}{0}})"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sp.collect(xa.det(),xa[0,:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh0AAAAXCAYAAACvZP2oAAAABHNCSVQICAgIfAhkiAAABjJJREFUeJztnV+IVUUcxz+rJsluqGSYUfaHEJSIlSKMcLlIFD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\quad - a_{{1}{1}} a_{{2}{2}} + a_{{1}{2}} a_{{2}{1}}, \\quad a_{{1}{0}} a_{{2}{1}} - a_{{1}{1}} a_{{2}{0}}\\right )$$"
      ],
      "text/plain": [
       "(a_{{1}{1}}⋅a_{{2}{2}} - a_{{1}{2}}⋅a_{{2}{1}}, -a_{{1}{1}}⋅a_{{2}{2}} + a_{{1\n",
       "}{2}}⋅a_{{2}{1}}, a_{{1}{0}}⋅a_{{2}{1}} - a_{{1}{1}}⋅a_{{2}{0}})"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa[1:,[1,2]].det(),xa[1:,[2,1]].det(),xa[1:,[0,1]].det()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**结论**：三阶行列式可以用二阶行列式表示。那么是否任意一个行列式都可以用较低的行列式表示？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在$n$阶行列式中，把元素$a_{ij}$所在的第i行和第j列划掉后，留下来的$n-1$阶行列式叫做元素$a_{ij}$的**余子式**,记做$M_{ij}$。把$A_{ij}={(-1)}^{i+j}M_{ij}$称为元素$a_{ij}$的代数余子式。如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}} & a_{{0}{2}}\\\\a_{{1}{0}} & a_{{1}{1}} & a_{{1}{2}}\\\\a_{{2}{0}} & a_{{2}{1}} & a_{{2}{2}}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{0}{0}}  a_{{0}{1}}  a_{{0}{2}}⎤\n",
       "⎢                                  ⎥\n",
       "⎢a_{{1}{0}}  a_{{1}{1}}  a_{{1}{2}}⎥\n",
       "⎢                                  ⎥\n",
       "⎣a_{{2}{0}}  a_{{2}{1}}  a_{{2}{2}}⎦"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "由代数余子式组成的伴随矩阵"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{1}{1}} a_{{2}{2}} - a_{{1}{2}} a_{{2}{1}} & - a_{{1}{0}} a_{{2}{2}} + a_{{1}{2}} a_{{2}{0}} & a_{{1}{0}} a_{{2}{1}} - a_{{1}{1}} a_{{2}{0}}\\\\- a_{{0}{1}} a_{{2}{2}} + a_{{0}{2}} a_{{2}{1}} & a_{{0}{0}} a_{{2}{2}} - a_{{0}{2}} a_{{2}{0}} & - a_{{0}{0}} a_{{2}{1}} + a_{{0}{1}} a_{{2}{0}}\\\\a_{{0}{1}} a_{{1}{2}} - a_{{0}{2}} a_{{1}{1}} & - a_{{0}{0}} a_{{1}{2}} + a_{{0}{2}} a_{{1}{0}} & a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{1}{1}}⋅a_{{2}{2}} - a_{{1}{2}}⋅a_{{2}{1}}   -a_{{1}{0}}⋅a_{{2}{2}} + a_{{\n",
       "⎢                                                                             \n",
       "⎢-a_{{0}{1}}⋅a_{{2}{2}} + a_{{0}{2}}⋅a_{{2}{1}}  a_{{0}{0}}⋅a_{{2}{2}} - a_{{0\n",
       "⎢                                                                             \n",
       "⎣a_{{0}{1}}⋅a_{{1}{2}} - a_{{0}{2}}⋅a_{{1}{1}}   -a_{{0}{0}}⋅a_{{1}{2}} + a_{{\n",
       "\n",
       "1}{2}}⋅a_{{2}{0}}  a_{{1}{0}}⋅a_{{2}{1}} - a_{{1}{1}}⋅a_{{2}{0}} ⎤\n",
       "                                                                 ⎥\n",
       "}{2}}⋅a_{{2}{0}}   -a_{{0}{0}}⋅a_{{2}{1}} + a_{{0}{1}}⋅a_{{2}{0}}⎥\n",
       "                                                                 ⎥\n",
       "0}{2}}⋅a_{{1}{0}}  a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}{1}}⋅a_{{1}{0}} ⎦"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa.adjugate().T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "因为行标和列标可唯一标识行列式的元素，所以行列式中每一个元素都分别对应着一个余子式和一个代数余子式。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**引理：**一个$n$阶行列式，如果其中第i行所有元素除$a_{ij}$外都为零，那么这个行列式等于$a_{ij}$与它的代数余子式的乘积，即$D=a_{ij}A_{ij}$。这是显而易见的。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.6.2.行列式按行（列）展开法则\n",
    "**定理3**：行列式等于它的任一行（列）的各元素与其对应的代数余子式乘积之和。即：$D=\\sum_{x=0}^n(a_{ix}A_{ix}),(i=0,1,\\dots,n)$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left ( a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}, \\quad \\left[\\begin{matrix}a_{{0}{0}} a_{{1}{1}} a_{{2}{2}} - a_{{0}{0}} a_{{1}{2}} a_{{2}{1}} - a_{{0}{1}} a_{{1}{0}} a_{{2}{2}} + a_{{0}{1}} a_{{1}{2}} a_{{2}{0}} + a_{{0}{2}} a_{{1}{0}} a_{{2}{1}} - a_{{0}{2}} a_{{1}{1}} a_{{2}{0}}\\end{matrix}\\right]\\right )$$"
      ],
      "text/plain": [
       "(a_{{0}{0}}⋅a_{{1}{1}}⋅a_{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{\n",
       "1}}⋅a_{{1}{0}}⋅a_{{2}{2}} + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{\n",
       "1}{0}}⋅a_{{2}{1}} - a_{{0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}, [a_{{0}{0}}⋅a_{{1}{1}}⋅a\n",
       "_{{2}{2}} - a_{{0}{0}}⋅a_{{1}{2}}⋅a_{{2}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⋅a_{{2}{2}\n",
       "} + a_{{0}{1}}⋅a_{{1}{2}}⋅a_{{2}{0}} + a_{{0}{2}}⋅a_{{1}{0}}⋅a_{{2}{1}} - a_{{\n",
       "0}{2}}⋅a_{{1}{1}}⋅a_{{2}{0}}])"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa.det(),sp.expand(xa[xn-1,:]*xa.adjugate().T[xn-1,:].T)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xa.det()==sp.expand(xa[xn-1,:].dot(xa.adjugate().T[xn-1,:]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**推论：**行列式任一行（列）的元素与另一行（列）的对应元素的代数余子式乘积之和等于零（基于性质4）。即：$D=\\sum_{x=0}^n(a_{ix}A_{jx})=0,(i,j=0,1,\\dots,n,i\\not =j)$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**分析：**我们以3阶行列式为例。<br>\n",
    "$a_{11}A_{11}+a_{12}A_{12}+a_{13}A_{13}=\\begin{vmatrix}a_{11}&a_{12}&a_{13}\\\\a_{21}&a_{22}&a_{23}\\\\a_{31}&a_{32}&a_{33} \\end{vmatrix}$<br>\n",
    "把第一行的元素换成第二行的对应元素，则：<br>\n",
    "${\\color{Red}{a_{21}}}A_{11}+a_{122}A_{12}+a_{23}A_{13}=\\begin{vmatrix}{\\color{Red}{a_{21}}}&a_{22}&a_{23}\\\\a_{21}&a_{22}&a_{23}\\\\a_{31}&a_{32}&a_{33} \\end{vmatrix}=0$<br>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.7.克拉默法则\n",
    "对于如下，二元线性方程组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left[\\begin{matrix}a_{{0}{0}} x_{0} + a_{{0}{1}} x_{1}\\\\a_{{1}{0}} x_{0} + a_{{1}{1}} x_{1}\\end{matrix}\\right] = \\left[\\begin{matrix}b_{0}\\\\b_{1}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡a_{{0}{0}}⋅x_{0} + a_{{0}{1}}⋅x_{1}⎤   ⎡b_{0}⎤\n",
       "⎢                                   ⎥ = ⎢     ⎥\n",
       "⎣a_{{1}{0}}⋅x_{0} + a_{{1}{1}}⋅x_{1}⎦   ⎣b_{1}⎦"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xn=2\n",
    "xa,xb,xx=getM('a',xn,xn),getM('b',xn,1),getM('x',xn,1)\n",
    "expr=sp.Eq(xa*xx,xb)\n",
    "expr"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "若令:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$\\left [ \\left[\\begin{matrix}a_{{0}{0}} & a_{{0}{1}}\\\\a_{{1}{0}} & a_{{1}{1}}\\end{matrix}\\right], \\quad \\left[\\begin{matrix}b_{0} & a_{{0}{1}}\\\\b_{1} & a_{{1}{1}}\\end{matrix}\\right], \\quad \\left[\\begin{matrix}a_{{0}{0}} & b_{0}\\\\a_{{1}{0}} & b_{1}\\end{matrix}\\right]\\right ]$$"
      ],
      "text/plain": [
       "⎡⎡a_{{0}{0}}  a_{{0}{1}}⎤  ⎡b_{0}  a_{{0}{1}}⎤  ⎡a_{{0}{0}}  b_{0}⎤⎤\n",
       "⎢⎢                      ⎥, ⎢                 ⎥, ⎢                 ⎥⎥\n",
       "⎣⎣a_{{1}{0}}  a_{{1}{1}}⎦  ⎣b_{1}  a_{{1}{1}}⎦  ⎣a_{{1}{0}}  b_{1}⎦⎦"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xd=[xa.copy() for _ in range(xn+1)]\n",
    "xd[1][:,0]=xb\n",
    "xd[2][:,1]=xb\n",
    "xd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "则上述二元线性方程组的解可表示为："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQMAAAAjCAYAAACQCm9JAAAABHNCSVQICAgIfAhkiAAABjBJREFUeJztnFtoHkUUx38x8dJoRVCh1gaRxqI0LWmLVSliIl5QW/EhooJCnoQKXhCxUkUiUguCIOqD+iARqT5YEeodtfZBClqp2mKxNVq8VBQ1rVTjpWp8ODtmu9/O7Hw7O3v5nB8spbPfnJn/+c432dndcyAQCAQsOBa4tupJpLAOeLPqSXigU3X5oFN95VPXAmC57uQRho7dwEPAG0XPqAAGgY+rnoQHOlWXDzrVVz517QFGgP52O64DLi58OsWwD7i+YJvjwFjBNtvFh65OpVN95VvXbOA14OjkCd2VwQCwDPfLlXuBHcAvwA/AU8AxjjZPBuYC/w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QKDz6Y3+PQCt7xnsBU7XdKz7M+3/O2nPoMsixEb9SYsP9Srz3rQOa5EkpUCzGUd+oKPVTiNQc1YjLzcBrduErcgzzOMNBnzk8vuwWRRN1Ku+13ZezS2CJvrKhabrXYj85oHWxeA95GaCrk5aF3LncXVk6Dqk7sFtDhPyYbMomqp3EZJr8UqBNrNoqq/y0gl6lwBbTB94FljfhkHX3PQsm5CvPoAvbPS2Oy9bvTZ+PAF5ZPSg5dg+CbGRrquduRUZG3Fm01o7oYULgU8153zkpvuqD6AYw0/Oet56DHn12uayrwJ+R9JryyTEhl1smObmOzbijJC4KkirZrQZyb46J9HuIzfdZ30Aha+c9Tz1GFz02uayv4TsMb9LOeeLEBv2saGbWxmxEWeURKUjXV21NcDtSL62wkduuq/6AHF85azr9LrYNFHnegYhNpoVG/3ASUit0//Q1TncgtxIXBZri+dw9yNJEuuZyeHW5VqbcrCzbFZJXr0uNk3UuZ5BiI1mxcbdkf3DPmMqenoLUmVFXT34yE33VR+gCPLqdbFpos71DEJsNCc2hoFP0Fcz0zIfuNHys1XlpuvafVN2PYYm1zMIsdGqa4j8c0v2tfXjHBxL+rfzwkPZuelV56yXXY+hyfUMQmzM4DI3l9hIrWgUCAQCgUAgEAgEAoFAIBAIBAKZ/Av9qub+orlLVgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left ( \\frac{- a_{{0}{1}} b_{1} + a_{{1}{1}} b_{0}}{a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}}, \\quad \\frac{a_{{0}{0}} b_{1} - a_{{1}{0}} b_{0}}{a_{{0}{0}} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}}\\right )$$"
      ],
      "text/plain": [
       "⎛     -a_{{0}{1}}⋅b_{1} + a_{{1}{1}}⋅b_{0}           a_{{0}{0}}⋅b_{1} - a_{{1}\n",
       "⎜─────────────────────────────────────────────, ──────────────────────────────\n",
       "⎝a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}{1}}⋅a_{{1}{0}}  a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}\n",
       "\n",
       "{0}}⋅b_{0}     ⎞\n",
       "───────────────⎟\n",
       "{1}}⋅a_{{1}{0}}⎠"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xd[1].det()/xd[0].det(),xd[2].det()/xd[0].det()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAU8AAAAjCAYAAAAUjIhnAAAABHNCSVQICAgIfAhkiAAAB81JREFUeJztnXuoFkUYh59TKml2r5OaJ6mstChNMpLSjCzR0soMCQuM6o8kKSS6iIjdMLIipHsQJ0rKEirtZnk5JUV2L8FI05IyrbxghpVmpz/eXc5xz+7s7M7Mt9+u88BSzu68+76zv292d3bmPeDxeDwe6/QB7gWOLNqREnAf8F7RTjiiyrFVnapeO9dx9QKuA7omHbCfovIQ4GXgJWCzXb8qyUDg66KdcESVY6s6Vb12ruP6DdgDLAeOzVKxC7AWGOTAqaqyAbjagd1mYKYDu1lwFZvHPVW9drWKayTSgXYg6clzNLAF+MKVRwUzA/gG+BP4HXgWOMDA3lHIY/5/wBJgJ3JXPNvMzczYjgvqJ7aqU9VrV/a4FgFNwGDdCg8D8xw4Ug80AHcB5yBjuiOQu9gdBjYvAlqRm815QD/gbWA90MnEWfSfPF3EBW5j8whVvXZViesD4Hbdg19Hxjr3FZ5GOqmQ0cB3wBpgcrvyBcA2YH6k/m3AP4hAQk5HLnDflLppNJP/tT0aV5IPKt/SYktqK48ZuppUtb9LXeZFV5OmcdnUZUvgtxZLKE/nORNpNNU2vN3xTcAcYCWwFXmd2A3cE+zvhDR4E9ANWAX0DPadD4yh44V+EZgbKTshOPdJKXWjTAt8CrfdwK5I2dCYemlxqXxQ+ZYWW1JbefTJq0mVVsGeLmeS7TemG1fS+U3jSquflRZi+sOkMc/9D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} a_{{1}{1}} - a_{{0}{1}} a_{{1}{0}}}\\right \\}$$"
      ],
      "text/plain": [
       "⎧            -a_{{0}{1}}⋅b_{1} + a_{{1}{1}}⋅b_{0}                  a_{{0}{0}}⋅\n",
       "⎨x_{0}: ─────────────────────────────────────────────, x_{1}: ────────────────\n",
       "⎩       a_{{0}{0}}⋅a_{{1}{1}} - a_{{0}{1}}⋅a_{{1}{0}}         a_{{0}{0}}⋅a_{{1\n",
       "\n",
       "b_{1} - a_{{1}{0}}⋅b_{0}     ⎫\n",
       "─────────────────────────────⎬\n",
       "}{1}} - a_{{0}{1}}⋅a_{{1}{0}}⎭"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sp.solve(expr,xx)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.7.1.克拉默法则\n",
    "如果线性方程组：<br>\n",
    "$\\begin{cases} a_{11}x_{1}+\\dots+a_{1n}x_{n}=b_{1}\\\\\\dots\\\\  a_{n1}x_{1}+\\dots+a_{nn}x_{n}=b_{n}\\end{cases}$<br>\n",
    "的系数行列式不等于零，即<br>\n",
    "$D=\\begin{vmatrix} a_{11}&\\dots&a_{1n}\\\\\\vdots&\\ddots&\\vdots\\\\a_{n1}&\\dots&a_{nn}\\end{vmatrix}\\not=0$<br>\n",
    "那么线性方程组有解且解是唯一的，解可以表示成：<br>\n",
    "$x_1=\\frac{D_1}{D},\\dots,x_n=\\frac{D_n}{D}$<br>\n",
    "其中，$D_j$是把系数行列式$D$中第$j$列的元素用方程组右端的常数项代替后所得到的$n$阶行列式，即<br>\n",
    "$D_j=\\begin{vmatrix} a_{11}&\\dots&a_{1,j-1}&b_{1}&a_{1,j+1}&\\dots&a_{1n}\\\\\\vdots&\\ddots&\\vdots&\\vdots&\\vdots&\\ddots&\\vdots\\\\a_{n1}&\\dots&a_{n,j-1}&b_{1}&a_{n,j+1}&\\dots&\\vdots\\end{vmatrix}$<br>\n",
    "定理中包含着三个结论：\n",
    "1. 方程组有解；\n",
    "2. 解是唯一的；\n",
    "3. 解可以由上面的公式给出。\n",
    "\n",
    "这三个结论是有联系的。应该注意，该定理所讨论的只是系数行列式不为零的方程组，至于系数行列式等于零的情形，将在后面的一般情形中一并讨论。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.7.2.关于克拉默法则的等价命题\n",
    "设$\\begin{cases} a_{11}x_{1}+\\dots+a_{1n}x_{n}=b_{1}\\\\\\dots\\\\  a_{n1}x_{1}+\\dots+a_{nn}x_{n}=b_{n}\\end{cases}$<br>\n",
    ">**定理4**：如果上述线性方程的系数行列式不等于零，则该线性方程组一定有解，而且解是唯一的。<br>\n",
    "**定理$4^{'}$**：如果线性方程组无解或有两个不同的解，则它的系数行列式必为零。\n",
    "\n",
    "常数项全为零的线性方程组称为**齐次线性方程组**，否则称为**非齐次线性方程组**。\n",
    "\n",
    "齐次线性方程组总是有解的，因为$(0,0,\\dots,0)$就是一个解，称为**零解**。因此，齐次线性方程组一定有零解，但不一定有非零解。\n",
    "\n",
    "我们关心的问题是，齐次线性方程组除零解以外是否存在着非零解。\n",
    "\n",
    "齐次线性方程组的相关定理：\n",
    ">* **定理5**：如果齐次线性方程组的系数行列式$D\\not=0$，则齐次线性方程组只有零解，没有非零解。\n",
    "* **定理$5^{'}$**：如果齐次线性方程组有非零解，则它的系数行列式必为零。\n",
    "\n",
    "备注：\n",
    ">1. 这两个结论说明系数行列式等于零是齐次线性方重组有非零解的必要条件。\n",
    "2. 在后面还将证明这个条件也是充分的。即：齐次线性方程组有非零解$\\leftrightarrow $系数行列式等于零。\n",
    "\n",
    "问：当线性方程组的系数行列式为零时，能否用克拉默法则解方程组？为什么？此时方程组的解为何？<br>\n",
    "答：当线性方程组的系数行列式为零时，不能用克拉默法则解方程组，因为此时方程组的解为无解或有无穷多解。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.7.3.小结\n",
    "1. 用克拉默法则解线性方程组的两个条件：\n",
    "    1. 方程个数等于未知量个数；\n",
    "    2. 系数行列式不等于零。\n",
    "2. 克拉默法则的意义主要在于建立了线性方程组的解和已知的系数以及常数项之间的关系。它主要适用于理论推导。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
